package cn.codelab.springcloudalibaba.study.step04.config;

import cn.codelab.springcloudalibaba.study.step04.interceptor.FeignAuthRequestInterceptor;
import feign.Logger;
import feign.Request;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

// 注意： 此处配置@Configuration注解就会全局生效(也就是对所有微服务都应用同一个日志配置)，如果想指定对应微服务生效，就不能配置@Configuration
//@Configuration
public class FeignConfig {
     /**
      * 日志级别
      * @return
      */
     @Bean
     public Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
     }

    /**
     * 自定义拦截器
     * @return
     */
    @Bean
    public FeignAuthRequestInterceptor feignAuthRequestInterceptor(){
        return new FeignAuthRequestInterceptor();
    }

    /**
     * 自定义超时时间
     * @return
     */
    @Bean
    public Request.Options options() {
        return new Request.Options(10L, TimeUnit.SECONDS, 30L, TimeUnit.SECONDS, true);
    }
 }